package com.fusuhai.service.imp;

import com.fusuhai.bean.DiseaseBean;
import com.fusuhai.bean.InsectBean;
import com.fusuhai.dao.DiseaseDao;
import com.fusuhai.service.DiseaseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class DiseaseServiceImp implements DiseaseService {
    @Resource
    private DiseaseDao diseaseDao;

    @Override
    public void addDisease(DiseaseBean disease) {
        diseaseDao.addDisease(disease);
    }

    @Override
    public InsectBean selectDisease(int id) {
        return diseaseDao.selectDisease(id);
    }

    @Override
    public PageInfo<InsectBean> selectDiseaseByName(int pageNO, int pageSize, String name, String symptom) {
        PageHelper.startPage(pageNO, pageSize);
        PageInfo<InsectBean> pageInfo=PageInfo.of(diseaseDao.selectDiseaseByName(name,symptom));
        return pageInfo;
    }

    @Override
    public PageInfo<InsectBean> selectAllDisease(int pageNO, int pageSize) {
        PageHelper.startPage(pageNO, pageSize);
        PageInfo<InsectBean> pageInfo=PageInfo.of(diseaseDao.selectAllDisease());
        return pageInfo;
    }
}
